from tests.pytests.helpers.codegen_helpers import compile_chunk, assert_code_contains


def test_assign_if():
    def assign_if(x: int) -> int:
        total = 0
        if x > 0:
            total = x
        return total

    block = compile_chunk(assign_if)
    assert_code_contains(
        block,
        """
        int assign_if(int x) {
            int total = 0;
            if (x > 0) {
                total = x;
            }
            return total;
        }
        """,
    )
